<template>
  <div class="home">
    <!--  搜索框 -->
    <search></search>

    <!-- 轮播图 -->
    <swiper></swiper>

    <!-- 商品目录 -->
    <category></category>

    <!-- 广告 -->
    <ad></ad>

    <!-- 商品推荐 -->
    <recommend></recommend>

    <!-- 休闲食品 -->
    <!-- 新鲜水果 -->
    <!-- 营养奶品 -->
    <floors></floors>

    <!-- 热销商品 -->
    <hotgoods></hotgoods>

    <!-- 底部菜单栏 -->
    <tab-bar></tab-bar>
  </div>
</template>
<script>
import search from "./components/search";
import swiper from "./components/swiper";
import category from "./components/category";
import ad from "./components/ad";
import recommend from "./components/recommend";
import floors from "./components/floors";
import hotgoods from "./components/hotgoods"
//import {getIndexInfo} from "@/request/api/home.js"
import * as api from "@/request/api/home.js";

export default {
  components: {
    search,
    swiper,
    category,
    ad,
    recommend,
    floors,
    hotgoods
  },
  data() {
    return {
      data: {}
    };
  },
  methods: {
    //获取首页信息接口
    //async init(){   //异步方法2:async await
    /*this.$httpRuest.get("http://vt.osssjk.com/goods/getIndexInfo")
        .then((res)=>{
          console.log(res)
        })*/ //异步方法1:Promise的.then用法
    //let res = await getIndexInfo()
    //console.log(res)

    async API_getIndexInfo() {
      return await api.getIndexInfo();
    }
  },
  async created() {
    let res = await this.API_getIndexInfo();
    //console.log(res)
    this.$eventBus.$emit("getIndexInfo", res.data.data);
  }
  /*created(){
      this.init()
    }*/
};
</script>

<style>
.home {
  background-color: #f0f0f0;
  padding-bottom: 50px;
}
</style>